package com.loop.unclelend.ui.adapter

import androidx.recyclerview.widget.RecyclerView
import com.loop.unclelend.R
import com.loop.unclelend.utils.ImageUtil
import com.loop.unclelend.utils.adapter.UncleRecyclerViewAdapter
import com.loop.unclelend.utils.adapter.UncleViewHolderHelper
import org.json.JSONObject

/**
 * UncleLend
 * @Author wwdeng
 * @CreateTime: 2024/9/28 13:45
 * @Annotation：意见反馈 - 图片列表
 */
class Adapter_Feedback_Image(recyclerView: RecyclerView?): UncleRecyclerViewAdapter<JSONObject>(recyclerView) {

    override fun getItemViewType(position: Int): Int {
        val model = getItem(position)
        if (model.optBoolean("isDefault",true)){
            return R.layout.uncle_item_feedback_add
        }
        return R.layout.uncle_item_feedback_image
    }
    override fun setItemChildListener(helper: UncleViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.img_remove) //删除
        helper.setItemChildClickListener(R.id.layout_add)//选择
    }

    override fun fillData(helper: UncleViewHolderHelper, position: Int, model: JSONObject) {
        //是否是默认图片
        if (!model.optBoolean("isDefault",true)){
            val ivImage = helper.getImageView(R.id.img_holder)
            ImageUtil.instance!!.loadImageUrl(mContext,ivImage,model.optString("imgPath"))
        }
    }
}